#ifndef _SHD_PIXEL_HLSL_
#define _SHD_PIXEL_HLSL_

#include "./shd_domain.hlsl"

//--------------------------------------------------------------------------------------
// Smooth shading pixel shader section
//--------------------------------------------------------------------------------------

// The pixel shader works the same as it would in a normal graphics pipeline.
// In this sample, it performs very simple N dot L lighting.

float4 PS( DS_OUTPUT Input ) : SV_TARGET {
	float4 color = float4( 0.0, 0.0, 0.0, 1.0 );

	float4 envir = float4( 1.0, 0.0, 0.0, 1.0 );

	color += 0.6 * envir;

	float3 light_pos = float3( 0.0, 100.0, -10.0 );
	light_pos = normalize( light_pos );
	float4 light_col = float4( 0.2, 0.5, 0.1, 1.0 );

	color += 0.4 * light_col * dot( light_pos, Input.vNormal );

	/**/
	float3 eye = g_vCameraPosWorld - Input.vWorldPos;
	eye = normalize(eye);

	float3 halfVec = eye + light_pos;
	halfVec = normalize(halfVec);

	float spec = saturate( dot( Input.vNormal, halfVec ) );

	spec = pow( spec, 4 );
	
	color += spec * float4( 1.0, 1.0, 1.0, 1.0 );
	/**/

	return normalize( color );
};

//--------------------------------------------------------------------------------------
// Solid color shading pixel shader (used for wireframe overlay)
//--------------------------------------------------------------------------------------
float4 SolidColorPS( DS_OUTPUT Input ) : SV_TARGET {
	return float4( 1.0, ( Input.vIndex % 2 == 0 ? 1.0 : 0.0 ), 0.0, 1.0 );
//	return float4( Input.vColor, 1 );
};


#endif // _SHD_PIXEL_HLSL_
